import { Sequelize } from "sequelize"

const { MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB } =
  process.env

const seq = new Sequelize(MYSQL_DB, MYSQL_USER, MYSQL_PASSWORD, {
  host: MYSQL_HOST,
  port: MYSQL_PORT,
  dialect: "mysql",
  timezone: "+08:00",
})

seq
  .authenticate()
  .then(() => {
    console.log("数据库连接成功")
  })
  .catch(() => {
    console.log("数据库连接失败")
  })

export default seq
